<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

</head>
<body>
<div id="app">
    <span style="color:red">{{msg}}</span><br v-if="msg!=null&&msg!=''"/>
    账号：<input type="text" v-model="userName"><br/>
    密码：<input type="password" v-model="password"><br/>
    <input type="button" value="登录" @click="login()">
</div>
<script src="js/vue.js"></script>
<script src="js/axios.js"></script>
</body>
<script>
    const app = Vue.createApp({
        data() {
            return {
                userName:"",
                password:"",
                msg:""
            }
        },
        methods: {
            async login(){
                let{data:res} = await axios({
                    url:"login",
                    method:"post",
                    data:{userName:this.userName,password:this.password}
                })
                if(res.data==1){
                    location.href='main.html'
                }else{
                    this.msg = res.msg
                }
            }
        }
    })
    app.mount("#app")
</script>
</html>